package com.eschool.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.eschool.pojo.CourseDAO;
import com.eschool.pojo.CourseVO;
import com.eschool.pojo.ScoreDAO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CourseMapper extends BaseMapper<CourseDAO> {

    @Select("SELECT c.coursename, c.teacher, c.room, c.courseid, " +
            "s.weekday, s.startTime, s.endTime, s.grade, s.scoreid, s.studentId, s.score " +
            "FROM score s " +
            "LEFT JOIN course c ON s.courseid = c.courseid " +
            "WHERE s.studentId = #{studentId} " +
            "AND (#{grade} IS NULL OR s.grade = #{grade})")
    List<CourseVO> getCourses(@Param("studentId") String studentId,
                                @Param("grade") String grade);
}
